const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');
let baseName = ''
let outputDirName = ''
let env = process.env.NODE_ENV
if (env == 'production') {
	// 生产环境
	baseName = '/ghwkClient';
	outputDirName = 'ghwkClient'
} else if (env == 'pre') {
	// 测试环境
	baseName = '/testghwkClient';
	outputDirName = 'testghwkClient'
} else if (env == 'mine') {
	baseName = '/h5';
	outputDirName = 'h5'
} else {
	// 本地环境
	baseName = '';
	outputDirName = 'docs'
}
module.exports = {
	outputDir: `${outputDirName}`,
	publicPath: `${baseName}/`,
	devServer: {
		disableHostCheck: true,
		open: process.platform === 'darwin',
		host: '0.0.0.0',
		port: 8888,
		https: false,
		hotOnly: false,
		// eslint-disable-next-line no-dupe-keys
		open: true,
		// 查阅 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/cli-service.md#配置代理
		proxy: {
			'/api': {
				target: 'http://www.imhqq.com:8077',
				changeOrigin: true,
				pathRewrite: {
					'^/api': ''
				}
			}
		},
		before: app => {}
	},
	lintOnSave: false, // eslint-loader 是否在保存的时候检查
	css: {
		loaderOptions: {
			postcss: {
				plugins: [
					autoprefixer(),
					pxtorem({
						rootValue: 37.5,
						propList: ['*']
					})
				]
			}
		}
	}
};
